package com.briup.jz.web.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.briup.jz.bean.BaseLog;
import com.briup.jz.service.ILogService;
import com.briup.jz.utils.Message;
import com.briup.jz.utils.MessageUtil;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@RestController
@Validated
@RequestMapping("/log")
@Api(description = "日志管理")
public class LogController {

    @Autowired
    private ILogService baselogService;

    @ApiOperation(value = "根据名称、类型分页查询物品类型信息")
    @ApiImplicitParams({
//    	@ApiImplicitParam(name="page",value = "当前页",paramType = "query",required = true),
//    	@ApiImplicitParam(name="pagesize",value = "每页大小",paramType = "query",required = true),
    })
    @GetMapping("pagequery")
    public Message query(Long page){
        List<BaseLog> list = baselogService.query(page);
        return MessageUtil.success(list);
    }

    @ApiOperation(value = "保存日志信息",notes="模型中具有id属性为更新，否则为保存")
    @ApiImplicitParams({
            @ApiImplicitParam(name="id",value = "主键",paramType = "query",dataType="long"),
            @ApiImplicitParam(name="realname",value = "访问人真实姓名",paramType = "query",dataType="string"),
            @ApiImplicitParam(name="method",value = "访问方式",paramType = "query",dataType="string"),
            @ApiImplicitParam(name="content",value = "访问路径",paramType = "query",dataType="string"),
            @ApiImplicitParam(name="logTime",value = "访问时间",paramType = "query",dataType="long"),
    })
    @PostMapping("save")
    public Message save(BaseLog baselog){
        baselogService.save(baselog);
        return MessageUtil.success("更新成功");
    }
	
}
